export default {
  // Global page headers: https://go.nuxtjs.dev/config-head
  target: 'server',
  hooks: {
    render:{
      route(url, result){
        result.html = result.html.replace(/data-n-head=\"ssr\"/gi, '')
      }
    },
    generate:{
      page(page){
        page.html = page.html.replace(/data-n-head=\"ssr\"/gi, '')
      }
    }
  },
  loading: {
    color: '#1393FF',
  },
  head: {
    title: '联合智为官网',
    htmlAttrs: {
      lang: 'zh-CN',
    },
    meta: [
      {
        charset: 'utf-8',
      },
      {
        name: 'viewport',
        content:
          'width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=no',
      },
      {
        name: 'applicable-device',
        content: 'pc,mobile',
      },
      {
        httpEquiv: 'Cache-Control',
        content: 'no-transform',
      },
      {
        httpEquiv: 'Cache-Control',
        content: 'no-siteapp',
      },
      {
        name: 'MobileOptimized',
        content: 'width',
      },
      {
        name: 'HandheldFriendly',
        content: 'true',
      },
      {
        name: 'keywords',
        content:
          '智慧工地云监管,智慧工地企业版,劳务实名制,塔吊监控系统,塔吊安全监控,智慧工地管理系统,智慧工地解决方案,实名制管理系统,人脸识别考勤机,智慧建筑',
      },
    ],
    link: [
      {
        rel: 'icon',
        type: 'image/x-icon',
        href: '/favicon.ico',
      },
      {
        rel: 'stylesheet',
        href: 'https://unpkg.com/swiper@8/swiper-bundle.min.css',
      },
    ],
    script: [
      {
        src: 'https://unpkg.com/swiper@8/swiper-bundle.min.js',
      },
      {
        src: 'https://cdn.jsdelivr.net/npm/vue-scrollto',
      },
      {
        src: '../baidu.js',
      },
      {
        src: '//api.map.baidu.com/api?v=2.0&ak=7ONWWfGb4ybz9LMw1Aj3gfNdSvyq8F1a',
      }
    ],
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: ['@/assets/css/tailwindcss.css'],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    // https://go.nuxtjs.dev/eslint
    '@nuxtjs/eslint-module',
    // https://go.nuxtjs.dev/tailwindcss
    '@nuxtjs/tailwindcss',
    '@nuxt/postcss8',
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: ['vue-scrollto/nuxt'],

  router: {
    scrollBehavior(to, from, savedPosition, next) {
      if (to.hash) {
        setTimeout(() => {
          return document.querySelector(to.hash).scrollIntoView({
            behavior: 'smooth',
          })
        }, 300)
      } else if (to.path === '/' && from.path.includes('/news/')) {
        return savedPosition
      }
      return {
        x: 0,
        y: 0,
      }
    },
  },
  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    extractCSS: {
      ignoreOrder: true
    },
    postcss: {
      plugins: {
        tailwindcss: {},
        autoprefixer: {},
      },
    },
  },
}
